<% layout('/layouts/default.html', {title: '问题管理', libs: ['fileupload','validate']}){ %>
<%
  if(has(taskId)){
	 question= @com.jeesite.modules.suggestion.util.Get.getQuestion(taskId);
  }
%>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header">
			<div class="box-title">
				<i class="fa icon-trophy"></i> ${text(question.isNewRecord ? '新增问题' : '编辑问题')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${question}" action="${ctx}/suggestion/question/save" method="post" class="form-horizontal">
			<#form:hidden path="questionCode"/>
			<#form:hidden name="taskId" value="${taskId!}"/>	
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('问题标题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="questionTitle" maxlength="64" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
							<span class="required">*</span> ${text('问题部门')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:treeselect id="office" title="${text('机构选择')}"
									path="office.officeCode" labelPath="office.officeName" 
									url="${ctx}/sys/office/treeData?isAll=true" class="required" allowClear="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('问题分类')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="questionType" dictType="sg_question_type" blankOption="true" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required">*</span> ${text('问题描述')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="2" maxlength="30" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
							<span class="required hide"></span> ${text('图片')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
							  	<#form:fileupload id="uploadImage" bizKey="${question.questionCode}" bizType="question_image"
									uploadType="image" class="" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2">附件：</label>
							<div class="col-sm-10">
								<#form:fileupload id="uploadFile" bizKey="${question.questionCode }" bizType="question_file"
									uploadType="all" readonly="false"/>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% if (!question.isNewRecord ){  %>
							 <button type="submit" onclick="$('#inputForm').attr('action','${ctx}/suggestion/question/submit')" class="btn btn-sm btn-danger" id="btnSubmitToAudit"><i class="fa fa-check"></i> ${text('提交')}</button>&nbsp;
						<%} %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>
